#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n, m;
	int a[105];
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int j = n - (m % n); j < n; j++) printf("%d ", a[j]);
	for (int k = 0; k < n - (m % n); k++) printf("%d ", a[k]);
	return 0;
}